// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者，助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2021 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件，未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
const VUE_APP_API_URL = 'https://www.atlanticmallccenter.com'; //spa 模式无需配置
// const VUE_APP_API_URL = 'http://192.168.31.106:8324';
const VUE_APP_WS_URL = 'wss://www.atlanticmallccenter.com'

//const MODE = 'universal'; //服务器渲染模式 (需要独立部署) 打包命令 npm run build
const MODE = 'spa'; //单页面形式渲染模式 (打包后将 dist目录覆盖到 public/pc 目录下) 打包命令: npm run generate

//(上方配置,不做独立部署无需修改)
import i18n from "./plugins/i18n"
module.exports = {
  env: {
    BASE_URL: VUE_APP_API_URL,
    WS_URL: VUE_APP_WS_URL
  },
  buildDir: 'nuxt-dist',
  mode: MODE,
  /*
   ** Headers of the page
   */
  head: {
    title: '加载中...',
    meta: [{
        charset: 'utf-8'
      },
      {
        name: 'apple-mobile-web-app-capable',
        content: "yes"
      },
      {
        name: 'viewport',
        content: 'width=device-width, initial-scale=1'
      },
      {
        hid: 'http-equiv',
        'http-equiv': "X-UA-Compatible",
        content: "IE=edge"
      },
      {
        hid: 'keywords',
        name: 'keywords',
        content: ''
      },
      {
        hid: 'description',
        name: 'description',
        content: ''
      }
    ],
    link: [{
      rel: 'icon',
      type: 'image/x-icon',
      href: '/favicon.ico'
    }],
    script: [],
  },
  /*
   ** Customize the progress-bar color
   */
  loading: {
    color: '#fff'
  },

  /*
   ** Plugins to load before mounting the App
   */
  plugins: [
    '@/plugins/i18n.js',
    '@/plugins/axios',
    {
      src: "./assets/iconfont/iconfont.js",
      ssr: false
    },
    {
      src: "~/plugins/vue-swiper.js",
      ssr: false
    },
    {
      src: '~/plugins/utils.js',
      ssr: false
    },
    {
      src: '~/plugins/debounce.js',
      ssr: false
    },
    {
      src: "~/plugins/element-ui",
      ssr: true
    },
    {
      src: "~/plugins/vueqr.js",
      ssr: false
    },
    {
      src: "~/plugins/vue-clipboard.js",
      ssr: false
    },
    '~/plugins/main'
  ],
  /*
   ** Nuxt.js modules
   */
  modules: [
    '@nuxtjs/axios',
    '@nuxtjs/auth',
    'cookie-universal-nuxt',
    'nuxt-sass-resources-loader'
  ],
  sassResources: [
    '~assets/theme/element-variables.scss'
  ],
  /*
   ** Global CSS
   */
  css: [
    "~assets/iconfont/iconfont.css",
    "~assets/css/index.scss",
    "element-ui/lib/theme-chalk/index.css",
    // "~theme/index.css",
    {
      src: "swiper/dist/css/swiper.css"
    }
  ],

  router: {
    middleware: ['auth']
  },

  auth: {
    strategies: {
      local: {
        _scheme: 'local',
        endpoints: {
          logout: {
            url: '/api/logout',
            method: 'post'
          },
          user: {
            url: '/api/user',
            method: 'get',
            propertyName: false
          }
        }
      },
      local1: {
        _scheme: 'local',
        endpoints: {
          login: {
            url: '/api/auth/login',
            method: 'post',
            propertyName: 'token'
          },
          logout: {
            url: '/api/logout',
            method: 'post'
          },
          user: {
            url: '/api/user',
            method: 'get',
            propertyName: false
          }
        }
      },
      local2: {
        _scheme: 'local',
        endpoints: {
          login: {
            // url: '/login/mobile',
            url: '/api/auth/smslogin',
            method: 'post',
            propertyName: 'token'
          },
          logout: {
            url: '/api/logout',
            method: 'post'
          },
          user: {
            url: '/api/user',
            method: 'get',
            propertyName: false
          }
        }
      }
    },
    redirect: {
      login: '/login',
      logout: '/',
      callback: '/login',
      home: false
    },
    cookie: {
      options: {
        maxAge: 60 * 60 * 24 * 7
      }
    },
    localStorage: false
  },

  axios: {
    baseURL: VUE_APP_API_URL,
    proxyHeaders: false,
    credentials: false,
    debug: `${process.env.NODE_ENV}` !== 'production',

  },
  /*
   ** Build configuration
   */
  distDir: 'build',
  /*
   ** Build configuration
   */
  build: {
    publicPath: '/pc/',
    publicPathFolder: MODE === 'spa' ? '/' : '',
    /*
     ** You can extend webpack config here
     */
    extend(config, ctx) {},
    babel: {
      "plugins": [
        [
          "component",
          {
            "libraryName": "element-ui",
            "styleLibraryName": "theme-chalk"
          }
        ]
      ]
    }
  },
  vendor: ['element-ui'],
  server: {
    port: 10822,
    host: '0.0.0.0', // default: localhost
  },
  i18n
}
